class Solution {
public:
    pair<int,TreeNode*> find(TreeNode* root){
        if(!root){
            return {0,NULL};
        }
        pair<int,TreeNode*> l = find(root->left);
        pair<int,TreeNode*> r = find(root->right);
        
        if(!l.second && !r.second){
            return {1+l.first,root};
        }
        if(!l.second || r.first > l.first){
            r.first += 1;
            return r;
        }
        return {l.first+1,l.second};
        
    }
    int findBottomLeftValue(TreeNode* root) {
        return find(root).second->val;
    }
};
